package mylogger

import "errors"

//log level （ unknown， info，trace，debug，error，fatal ）

type Loglevel uint16

const (
	UNKNOW Loglevel = iota
	DEBUG
	TRACE
	INFO
	WARNING
	ERROR
	FATAL
)

func parse(loglevelstring string) (Loglevel, error) {
	switch loglevelstring {
	case "info":
		return INFO, nil
	case "trace":
		return TRACE, nil
	case "debug":
		return DEBUG, nil
	case "warning":
		return WARNING, nil
	case "error":
		return ERROR, nil
	case "fatal":
		return FATAL, nil
	default:
		return UNKNOW, errors.New("无效log类型")
	}
}
